package edu.guet.server.controller;


import edu.guet.server.model.UHomework;
import edu.guet.server.model.vo.StuHmkVO;
import edu.guet.server.service.TeacherHmkService;
import edu.guet.server.service.UnitTestService;
import edu.guet.server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 教师对作业进行批阅
 */
@RestController
@RequestMapping("/teacher/homework")
public class TeacherHomeworkController {

    @Autowired
    TeacherHmkService teacherHmkService;
    @Autowired
    private UnitTestService unitTestService;

    @GetMapping("/{hmk_id}")
    public ResultAPI getHomework(@PathVariable Integer hmk_id) {
        UHomework uHomework=teacherHmkService.getHmkByid(hmk_id);
        return ResultAPI.success(uHomework);
    }

    /**
     * 教师修改作业内容
     * @param uHomework
     * @return
     */
    @PutMapping
    public ResultAPI UpdateHomework(@RequestBody UHomework uHomework) {
        return teacherHmkService.updateHmk(uHomework);
    }
    @DeleteMapping("{hmk_id}")
    public ResultAPI DeleteHomework(@PathVariable Integer hmk_id) {
        return teacherHmkService.deleteHmk(hmk_id);
    }
    @PostMapping
    public ResultAPI AddHomework(@RequestBody UHomework uHomework) {
        return teacherHmkService.insertHmk(uHomework);
    }
    @GetMapping("/getHmklist")
    public ResultAPI getHmklistbySem(@RequestParam Integer semester_id) {
        return teacherHmkService.getHmklistbySem(semester_id);
    }
    @GetMapping("/getlistByhmkid")
    public ResultAPI getlistByhmkid(@RequestParam Integer hmk_id) {
        return teacherHmkService.getlistByhmkid(hmk_id);
    }
    @PutMapping("/grade")
    public ResultAPI updateGrade(@RequestBody StuHmkVO uHomework) {
        return teacherHmkService.updateGrade(uHomework);
    }

}
